package com.example.a001.part07;

import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;

import androidx.activity.EdgeToEdge;
import androidx.appcompat.app.AppCompatActivity;
import androidx.core.graphics.Insets;
import androidx.core.view.ViewCompat;
import androidx.core.view.WindowInsetsCompat;

import com.example.a001.R;

public class part701Activity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        EdgeToEdge.enable(this);
        setContentView(R.layout.activity_part701);

        // 获取 TextView 的引用
        TextView nameTextView = findViewById(R.id.nameTextView);
        TextView idTextView = findViewById(R.id.idTextView);

        // 获取 EditText 的引用
        EditText nameEditText = findViewById(R.id.editText);
        EditText idEditText = findViewById(R.id.editText2);

        // 获取 Button 的引用
        Button submitButton = findViewById(R.id.button);

        // 设置 Button 的点击事件监听器
        submitButton.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                // 获取 EditText 的文本
                String name = nameEditText.getText().toString();
                String id = idEditText.getText().toString();

                // 更新 TextView 的内容
                nameTextView.setText(name);
                idTextView.setText(id);
            }
        });

        ViewCompat.setOnApplyWindowInsetsListener(findViewById(R.id.main), (v, insets) -> {
            Insets systemBars = insets.getInsets(WindowInsetsCompat.Type.systemBars());
            v.setPadding(systemBars.left, systemBars.top, systemBars.right, systemBars.bottom);
            return insets;
        });
    }
}
